<template>
	<el-dialog
		:visible="true"
		width="80%"
		:destroy-on-close="true"
		class="rempadding"
		:before-close="handleClose"
	>
		<div slot="title" class="dialog-title">
			<el-form :inline="true" label-width="auto">
				<el-row>
					<el-col :span="24">
						<el-form-item
							:label="$t('common.agent_number') + ' : '"
						>
							{{ rowVal.proxyName }}
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
		</div>
		<el-table
			v-loading="loading"
			size="mini"
			border
			:data="tableData"
			class="small-size-table"
			style="margin-bottom: 15px"
			:header-cell-style="getRowClass"
			element-loading-spinner="el-icon-loading"
			highlight-current-row
		>
			<el-table-column
				key="staticsDate"
				prop="staticsDate"
				align="center"
				min-width="150"
				:label="$t('report.date')"
				show-overflow-tooltip
			>
				<template slot-scope="scope">
					{{ scope.row.staticsDate || '-' }}
				</template>
			</el-table-column>
			<el-table-column
				prop="betAmount"
				align="center"
				:label="$t('report.total_bet_amount')"
				min-width="150"
				show-overflow-tooltip
			>
				<template slot-scope="scope">
					{{ handleCurrency(rowVal.currency) }}
					{{ handleNumber(rowVal.currency, scope.row.betAmount) }}
				</template>
			</el-table-column>
			<el-table-column
				prop="validBetAmount"
				align="center"
				:label="$t('report.total_valid_bet_amount')"
				min-width="150"
				show-overflow-tooltip
			>
				<template slot-scope="scope">
					{{ handleCurrency(rowVal.currency) }}
					{{
						handleNumber(rowVal.currency, scope.row.validBetAmount)
					}}
				</template>
			</el-table-column>
			<el-table-column
				prop="memberCount"
				align="center"
				:label="$t('report.member_count')"
				show-overflow-tooltip
			>
				<template slot-scope="scope">
					{{ handleNumber('', scope.row.memberCount, 0) }}
				</template>
			</el-table-column>
			<el-table-column
				prop="betCount"
				align="center"
				:label="$t('report.bet_count')"
				show-overflow-tooltip
			>
				<template slot-scope="scope">
					{{ handleNumber('', scope.row.betCount, 0) }}
				</template>
			</el-table-column>
			<el-table-column
				prop="netAmount"
				:label="`${$t('dxn.card_ables_list.member_total_winorloss')}`"
				min-width="130"
				align="center"
				show-overflow-tooltip
			>
				<template slot-scope="scope">
					<span :style="handleNumberColor(scope.row.netAmount)">
						{{ handleCurrency(rowVal.currency) }}
						{{ handleNumber(rowVal.currency, scope.row.netAmount) }}
					</span>
				</template>
			</el-table-column>
			<el-table-column
				prop="memberRebateAmountByProxy"
				align="center"
				label="代理发放会员返水"
				show-overflow-tooltip
			>
				<template slot-scope="scope">
					{{ handleCurrency(scope.row.currency) }}
					{{
						handleNumber(
							scope.row.currency,
							scope.row.memberRebateAmountByProxy
						)
					}}
				</template>
			</el-table-column>
			<el-table-column
				prop="memberRebateAmountByPlat"
				align="center"
				label="平台发放会员返水"
				show-overflow-tooltip
			>
				<template slot-scope="scope">
					{{ handleCurrency(scope.row.currency) }}
					{{
						handleNumber(
							scope.row.currency,
							scope.row.memberRebateAmountByPlat
						)
					}}
				</template>
			</el-table-column>
			<el-table-column
				prop="memberArtificialPatchAmount"
				align="center"
				label="会员返水其他调整"
				show-overflow-tooltip
			>
				<template slot-scope="scope">
					{{ handleCurrency(scope.row.currency) }}
					{{
						handleNumber(
							scope.row.currency,
							scope.row.memberArtificialPatchAmount
						)
					}}
				</template>
			</el-table-column>
			<el-table-column
				prop="memberNetwinAmount"
				align="center"
				label="会员净盈亏"
				show-overflow-tooltip
			>
				<template slot-scope="scope">
					<span :style="handleNumberColor(scope.row.netProfit)">
						{{ handleCurrency(scope.row.currency) }}
						{{
							handleNumber(
								scope.row.currency,
								scope.row.memberNetwinAmount
							)
						}}
					</span>
				</template>
			</el-table-column>
		</el-table>
		<!-- 分页 -->
		<el-pagination
			v-show="!!total"
			class="text-right"
			:current-page.sync="pageNum"
			background
			layout="total, sizes,prev, pager, next, jumper"
			:page-size.sync="pageSize"
			:page-sizes="pageSizes"
			:total="total"
			:pager-count="9"
			@current-change="handleCurrentChange"
			@size-change="handleSizeChange"
		></el-pagination>
		<div slot="footer" class="dialog-footer" style="text-align: center">
			<el-button type="primary" @click="handleClose">关闭</el-button>
		</div>
	</el-dialog>
</template>
<script>
import list from '@/mixins/list'
import summaryList from './summaryList'
export default {
	mixins: [list, summaryList],
	props: {
		rowVal: {
			type: Object,
			default: () => {}
		},
		closeDialog: {
			type: Function,
			default: () => {}
		}
	},
	data() {
		return {
			loading: false,
			tableData: [],
			subSummary: {}
		}
	},
	methods: {
		loadData() {
			const httpStr =
				this.rowVal.dateFlag === '0'
					? 'getReportProxyNetAmountDayDetail'
					: 'getReportProxyNetAmountMonthDetail'
			this.loading = true
			this.rowVal.pageNum = this.pageNum
			this.rowVal.pageSize = this.pageSize
			this.$api[httpStr](this.rowVal)
				.then((res) => {
					this.loading = false
					if (res.code === 200) {
						this.tableData = []
						this.tableData = res?.data?.record || []
						this.subSummary = res?.data?.summary || {}
						this.total = res?.data?.totalRecord || 0
					}
				})
				.catch(() => {
					this.loading = false
				})
		},
		handleClose() {
			this.closeDialog(false)
		}
	}
}
</script>
<style lang="scss" scoped>
.fenye {
	text-align: center;
}
::v-deep .el-table__body-wrapper {
	overflow-y: auto;
	max-height: 45vh;
}
</style>
